package org.boge.wxnovel.service;

import com.github.pagehelper.PageInfo;
import org.boge.wxnovel.bean.Genres;
import org.boge.wxnovel.bean.NovelDetail;
import org.boge.wxnovel.dao.NovelDetailDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class NovelDetailService {
    @Autowired
    private NovelDetailDao novelDetailDao;
    public PageInfo<NovelDetail> searchByName(String key,Integer pageSize,Integer pageNum){
        return new PageInfo<>(novelDetailDao.findByNovelName(key,pageNum,pageSize));
    }

    public PageInfo<NovelDetail> searchByDesc(String key,Integer pageSize,Integer pageNum){
        return new PageInfo<>(novelDetailDao.findByDescription(key,pageNum,pageSize));
    }

    public PageInfo<NovelDetail> getAll(Integer pageSize,Integer pageNum){
        return new PageInfo<>(novelDetailDao.findAll(pageSize,pageNum));
    }

    public PageInfo<NovelDetail> getByGenres(Integer genresId, Integer pageSize, Integer pageNum){
        return new PageInfo<>(novelDetailDao.findByGenres(genresId,pageNum,pageSize));
    }

    public PageInfo<NovelDetail> getByGenres(Genres genres, Integer pageSize, Integer pageNum){
        return new PageInfo<>(novelDetailDao.findByGenres(genres,pageNum,pageSize));
    }
}
